package com.wang.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wang.domain.TongueDiagnosis;
import com.wang.domain.enums.DiagnosisCoatedEnum;
import com.wang.mapper.TongueDiagnosisMapper;
import com.wang.service.TongueDiagnosisService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author WangZai
 * @since 2023-04-27
 */
@Service
public class TongueDiagnosisServiceImpl extends ServiceImpl<TongueDiagnosisMapper, TongueDiagnosis> implements TongueDiagnosisService {

    @Override
    public boolean saveTongueDiagnosis(TongueDiagnosis tongueDiagnosis) {
        return this.save(tongueDiagnosis);
    }

    @Override
    public boolean deleteTongueDiagnosisById(Integer tongueDiagnosisId) {
        return this.removeById(tongueDiagnosisId);
    }

    @Override
    public TongueDiagnosis getTongueDiagnosisById(Integer tongueDiagnosisId) {
        return this.getById(tongueDiagnosisId);
    }

    @Override
    public List<TongueDiagnosis> getTongueDiagnosisListByUserId(Integer userId) {
        QueryWrapper<TongueDiagnosis> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_id", userId);
        return this.list(queryWrapper);
    }

    @Override
    public List<TongueDiagnosis> getAllDiagnosis() {
        return this.list();
    }

    @Override
    public Integer getCoatedNum(Integer coatedEnumCode) {
        QueryWrapper<TongueDiagnosis> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("coated", coatedEnumCode);
        return this.count(queryWrapper);
    }

    @Override
    public Integer getColorNum(Integer colorEnumCode) {
        QueryWrapper<TongueDiagnosis> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("color", colorEnumCode);
        return this.count(queryWrapper);
    }

    @Override
    public Integer getCrackNum(Integer crackEnumCode) {
        QueryWrapper<TongueDiagnosis> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("crack", crackEnumCode);
        return this.count(queryWrapper);
    }

    @Override
    public Integer getIndentNum(Integer indentEnumCode) {
        QueryWrapper<TongueDiagnosis> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("indentation", indentEnumCode);
        return this.count(queryWrapper);
    }


}
